#coding:utf-8
from users.models import UserProfile

__author__ = 'luning'
__date__ = '2018/5/18'
#引入Django表单
from django import forms
#引入验证码field
from captcha.fields import CaptchaField

#登陆表单验证
class LoginForm(forms.Form):
    #用户名密码不能为空
    username = forms.CharField(required=True)
    password = forms.CharField(required=True,max_length=8)


#验证码form & 注册表单form
class RegisterForm(forms.Form):
    #此处email与前端name需要保持一致
    email = forms.EmailField(required=True)
    #密码不能小于5位
    password = forms.CharField(required=True,min_length=5)
    #应用验证码
    captcha = CaptchaField()


#激活时验证码实现
class ActiveForm(forms.Form):
    #激活时不对邮箱密码做验证
    #应用验证码 自定义错误输出key必须与异常一样
    captcha = CaptchaField(error_messages={"invalid":u"验证码错误"})

#注册验证码实现
class ForgetForm(forms.Form):
    #此处email与前端name需要保持一致
    email = forms.EmailField(required=True)
    # 应用验证码 自定义错误输出key必须与异常一样
    captcha = CaptchaField(error_messages={"invalid": u"验证码错误"})

#重置密码form实现
class ModifyPwdForm(forms.Form):
    #密码不能小于8位
    password1 = forms.CharField(required=True,min_length=8)
    password2 = forms.CharField(required=True,min_length=8)

#用于文件上传，修改头像
class UploadImageForm(forms.ModelForm):

    class Meta:
        model = UserProfile
        fields = ['image']

# 用于个人中心修改个人信息
class UserInfoForm(forms.ModelForm):

    class Meta:
        model = UserProfile
        fields = ['nick_name','gender','birthday','address','mobile']

